﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Report.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   Defines the Report type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.Silverlight.StreetCareAPI
{
    #region Using Directives

    using System;
    using System.Linq;
    using Microsoft.Maps.MapControl;

    #endregion

    /// <summary>
    /// Defines the Report type.
    /// </summary>
    public partial class Report
    {
        /// <summary>
        /// Gets the report rating.
        /// </summary>
        public double ReportRating
        {
            get
            {
                return this.Comments.Average(c => c.CommentRating);
            }
        }

        /// <summary>
        /// Gets the map location.
        /// </summary>
        /// <value>The map location.</value>
        public Location ReportMapLocation
        {
            get { return new Location(ReportLatitude, ReportLongitude); }
        }

        /// <summary>
        /// Gets the report icon.
        /// </summary>
        public Uri ReportIcon
        {
            get { return new Uri(Category.CategoryImageUrl, UriKind.Relative); }
        }

        /// <summary>
        /// Gets a value indicating whether [report image visible].
        /// </summary>
        /// <value><c>true</c> if [report image visible]; otherwise, <c>false</c>.</value>
        public bool ReportImageVisible
        {
            get { return !string.IsNullOrEmpty(this.ReportImageUrl); }
        }

        /// <summary>
        /// Gets a value indicating whether [report fixed image visible].
        /// </summary>
        /// <value>
        ///    <c>true</c> if [report fixed image visible]; otherwise, <c>false</c>.
        /// </value>
        public bool ReportFixedImageVisible
        {
            get { return !string.IsNullOrEmpty(this.ReportFixedImageUrl); }
        }
    }
}
